<template>
    <el-dialog
        title="删除站点"
        :visible="visible"
        :before-close="onCancel"
    >
        <div>
            <el-checkbox v-model="form.webroot">删除同名根目录?</el-checkbox>
        </div>
        <div slot="footer">
            <el-button @click="onCancel">取消</el-button>
            <el-button type="primary" @click="onSumit">确定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import { delSite } from "@/api/site"
    export default {
        name: "delete-site",
        props: ['visible', 'siteId'],
        data () {
            return {
                form: {
                    webroot: false,
                    site_id: 0
                }
            }
        },
        methods: {
            onCancel () {
                this.webroot = false
                this.$emit('onClose')
            },
            onSumit () {
                this.form.site_id = this.siteId
                delSite(this.form).then(res => {
                    console.log(res)
                    if (res.code > 0) {
                        this.onCancel()
                        this.$message.success("删除成功")
                        this.$emit("onSuccess")
                    }
                })
            }
        }
    }
</script>